//
//  ArrowView.m
//  International_Hospital
//
//  Created by 喵小仲 on 16/7/6.
//  Copyright © 2016年 LiYiLin. All rights reserved.
//

#import "ArrowView.h"

@implementation ArrowView

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    //背景颜色
    self.backgroundColor = [UIColor whiteColor];
    
    self.layer.cornerRadius = kLLCornerRadius;
}

#pragma mark
#pragma mark -- 设置子控件
- (void)setupUIWithPlaceHolder:(NSString *)string
{
    //输入框
    UITextField *textField = [[UITextField alloc] init];
    self.textField = textField;
    self.placeHolderString = string;
    textField.placeholder = string;
    textField.textColor = [UIColor blackColor];
    textField.enabled = NO;
    [self addSubview:textField];
    
    //细小的蓝色View
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:view];
    
    //尖括号型的button
    UIButton *button = [[UIButton alloc] init];
    [button setImage:[UIImage imageNamed:@"illness_button_input_blue.png"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(didClickAnalyseButton:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:button];
    
    //各种约束
    [button makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.right.offset(-kLLMarginLeft);
        make.width.offset(kLLArrowViewButtonWidth);
        make.height.offset(kLLArrowViewButtonWidth);
    }];
    
    [view makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.width.offset(1);
        make.height.offset(kLLWhiteViewHeight * 0.6);
        make.right.equalTo(button.left).offset(-kLLMarginLeft);
    }];
    
    [self.textField makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.offset(kLLMarginLeft);
        make.right.equalTo(view.left).offset(-kLLNewMargin);
    }];
    
    self.textField.font = kLLFontSize;
}

#pragma mark
#pragma mark -- 点击Button
- (void)didClickAnalyseButton:(UIButton *)button
{
    if ([self.delegate respondsToSelector:@selector(didButtonDelegate:)])
    {
        [self.delegate didButtonDelegate:self];
    }
}



@end
